{layout name="common/layout" /}

<style>
    .swiper-container {
        width: 100%;
        height: 300px;
        margin-left: auto;
        margin-right: auto;
    }

    .swiper-slide {
        background-size: cover;
        background-position: center;
    }

    .gallery-top {
        height: 80%;
        width: 100%;
    }

    .gallery-thumbs {
        height: 20%;
        box-sizing: border-box;
        padding: 10px 0;
    }

    .gallery-thumbs .swiper-slide {
        width: 25%;
        height: 100%;
        opacity: 0.4;
    }
    .gallery-thumbs .swiper-slide-thumb-active {
        opacity: 1;
    }

    .article-image {
        height: 600px;
    }

    @media (max-width: 767px) {

        .article-image {
            height: 400px;
        }
    }

</style>

<div class="container" id="content-container">

    <div class="row">

        <main class="col-xs-12 col-md-8">

            <div class="panel panel-default article-content">
                <div class="panel-heading">
                    <ol class="breadcrumb">
                        <!-- S 面包屑导航 -->
                        {cms:breadcrumb id="item"}
                        <li><a href="{$item.url}">{$item.name|htmlentities}</a></li>
                        {/cms:breadcrumb}
                        <!-- E 面包屑导航 -->
                    </ol>
                </div>
                <div class="panel-body">
                    <div class="article-metas">
                        <h1 class="metas-title" {if $__ARCHIVES__.style}style="{$__ARCHIVES__.style_text}"{/if}>
                            {cms:archives name="title|htmlentities" /}
                        </h1>
                        <!-- S 统计信息 -->
                        <div class="metas-body">
                            <span class="views-num">
                                <i class="fa fa-eye"></i> {cms:archives name="views" /} 阅读
                            </span>
                            <span class="comment-num">
                                <i class="fa fa-comments"></i> {cms:archives name="comments" /} 评论
                            </span>
                            <span class="like-num">
                                <i class="fa fa-thumbs-o-up"></i>
                                <span class="js-like-num"> {cms:archives name="likes" /} 点赞
                                </span>
                            </span>
                        </div>
                        <!-- E 统计信息 -->
                    </div>

                    {if $__ARCHIVES__.ispaid}
                    <div class="article-image mt-4">
                        {if isset($__ARCHIVES__.productdata) && $__ARCHIVES__.productdata}
                        <div class="swiper-container gallery-top">
                            <div class="swiper-wrapper">
                                {volist name="$__ARCHIVES__.productdata|explode=',',###" id="image"}
                                <div class="swiper-slide" data-src="{$image|cdnurl}" style="background-image:url({$image|cdnurl})"></div>
                                {/volist}
                            </div>
                            <div class="swiper-button-next swiper-button-white"></div>
                            <div class="swiper-button-prev swiper-button-white"></div>
                        </div>
                        <div class="swiper-container gallery-thumbs">
                            <div class="swiper-wrapper">
                                {volist name="$__ARCHIVES__.productdata|explode=',',###" id="image"}
                                <div class="swiper-slide" style="background-image:url({$image|cdnurl})"></div>
                                {/volist}
                            </div>
                        </div>
                        {/if}
                    </div>
                    {/if}

                    <div class="article-text">
                        <!-- S 正文 -->
                        <p>
                            {if $__ARCHIVES__.is_paid_part_of_content || $__ARCHIVES__.ispaid}
                            {cms:archives name="content" /}
                            {/if}
                        </p>
                        <!-- E 正文 -->
                    </div>

                    {include file="common/payment" /}

                    {include file="common/donate" /}

                    {include file="common/share" type="archives" image="__ARCHIVES__.image" aid="__ARCHIVES__.id"}

                    {include file="common/metainfo" /}

                    {include file="common/related" /}

                    <div class="clearfix"></div>
                </div>
            </div>

            {if $config.iscomment && config('fastadmin.usercenter')}
            <div class="panel panel-default" id="comments">
                <div class="panel-heading">
                    <h3 class="panel-title">{:__('Comment list')}
                        <small>共有 <span>{cms:archives name="comments" /}</span> 条评论</small>
                    </h3>
                </div>
                <div class="panel-body">
                    {if $__ARCHIVES__.iscomment}
                    {include file="common/comment" type="archives" aid="__ARCHIVES__.id"}
                    {else/}
                    <div class="text-muted text-center">评论功能已关闭</div>
                    {/if}
                </div>
            </div>
            {/if}

        </main>

        <aside class="col-xs-12 col-md-4">
            {include file="common/authorinfo" /}
            {include file="common/sidebar" /}
        </aside>

    </div>
</div>
<script data-render="script">
        var galleryThumbs = new Swiper('.gallery-thumbs', {
            spaceBetween: 10,
            slidesPerView: 5,
            freeMode: true,
            watchSlidesVisibility: true,
            watchSlidesProgress: true,
        });
        var galleryTop = new Swiper('.gallery-top', {
            spaceBetween: 10,
            navigation: {
                nextEl: '.swiper-button-next',
                prevEl: '.swiper-button-prev',
            },
            thumbs: {
                swiper: galleryThumbs
            }
        });
        //点击放大
        $(document).on("click", ".article-image .gallery-top .swiper-slide", function () {
            var data = [];
            $.each($(this).parent().children(), function (i, j) {
                data.push({
                    "src": $(this).data("src")
                });
            });
            var json = {
                "title": "",
                "start": $(this).index(),
                "data": data
            };
            layer.photos(JSON.parse(JSON.stringify({photos: json})));
        });
</script>
